package com.snow.vpnclient.data;

import com.snow.vpnclient.dto.LocationDto;

/**
 * @author liufq
 * @since 2023-03-18 09:58:09
 */
public class LocalStorage {

    private static String portal;

    public static Integer tcpPort;

    public static LocationDto cacheLocation;

    // client api server
    // portal url demo https://192.168.1.222:10303/login
    // client api url demo https://192.168.1.222:10303
    public static String getClientApiServer() {
        if (portal.endsWith("/login")) {
            return portal.substring(0, portal.lastIndexOf("/login"));
        } else if (portal.endsWith("/login/")) {
            return portal.substring(0, portal.lastIndexOf("/login/"));
        } else {
            return portal;
        }
    }

    public static void setTcpPort(Integer tcpPort) {
        LocalStorage.tcpPort = tcpPort;
    }

    public static void setPortal(String portal) {
        LocalStorage.portal = portal;
    }
}
